using ASP;
using HoWave.Common;
using HoWave.Data;
using HoWave.Data.Bll;
using HoWave.Data.Model;
using HoWave.Web.Shop;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class ShopOutStockLogAdd : Shop, IRequiresSessionState
{
	private int productID = 0;
	protected UserControls_cmpy_Top top1;
	protected Literal ltrProductname;
	protected TextBox txtEmail;
	protected TextBox txtMobilePhone;
	protected TextBox txtBookCount;
	protected Button btnSave;
	protected UserControls_CMYP_Foot foot1;
	protected HtmlForm form1;
	public int ProductID
	{
		get
		{
			if (base.Request.QueryString["ProductID"] != null)
			{
				this.productID = Convert.ToInt32(base.Request.QueryString["ProductID"].Trim());
			}
			return this.productID;
		}
	}
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.IsPostBack)
		{
			if (this.ProductID > 0)
			{
				string sql = "select ProductName from HLShop_Product where ProductID=" + this.ProductID;
				DataTable dataTable = this.conn.GetDataTable(sql);
				if (dataTable.Rows.Count > 0)
				{
					this.ltrProductname.Text = dataTable.Rows[0]["ProductName"].ToString() + "；";
					this.txtEmail.Text = base.user.UserEmail;
					this.txtMobilePhone.Text = base.user.UserInforRes["MobilePhone"].ToString();
				}
			}
		}
	}
	private bool CheckInput()
	{
		bool result = true;
		string text = this.txtEmail.Text.Trim();
		if (text != "")
		{
			if (!PageValidate.IsEmail(text))
			{
				this.txtEmail.Focus();
				MessageBox.Show(this, "Email地址格式不正确！");
				result = false;
			}
		}
		return result;
	}
	protected void btnSave_Click(object sender, EventArgs e)
	{
		if (this.CheckInput())
		{
			string text = this.txtEmail.Text;
			string text2 = this.txtMobilePhone.Text;
			int value = int.Parse(this.txtBookCount.Text);
			HoWave.Data.Model.OutStockLog outStockLog = new HoWave.Data.Model.OutStockLog();
			outStockLog.UserID = new int?(base.user.UserID);
			outStockLog.Email = text;
			outStockLog.MobilePhone = text2;
			outStockLog.ProductID = new int?(this.ProductID);
			outStockLog.BookCount = new int?(value);
			outStockLog.InputDate = new DateTime?(DateTime.Now);
			outStockLog.EmailStatus = false;
			outStockLog.MobileStatus = false;
			outStockLog.MessageStatus = false;
			outStockLog.NoticeStatue = 0;
			outStockLog.NoticeDate = new DateTime?(DateTime.Now);
			int num = BLLInstance.BllOutStockLog.Add(outStockLog);
			if (num > 0)
			{
				this.WriteSuccessMsg("", "登记成功！", "member/Index.aspx?mainurl=MyShop.aspx");
			}
			else
			{
				this.WriteErrMsg("", "登记失败！", "");
			}
		}
	}
}
